package BasicClass.Five;

public class Test_Five {
    public static void main(String[] args) {
        int[] ints = {1,2,3,4,5,6,7,8};
        TreeNode node = null;
        for (int i = 0; i < 3; i++) {
            node = new TreeNode(ints[i]);
            node.left = new TreeNode(ints[i*2+1]);
            node.right = new TreeNode(ints[i*2+2]);
        }
        f(node);
    }

    public static void f(TreeNode head){
        if(head == null){
            return;
        }
        System.out.println(head.val);
        //1,打印语句放置，则打印先序遍历
        f(head.left);
        //2,打印语句放置，则打印中序遍历
        f(head.right);
        //3,打印语句放置，则打印后序遍历
    }



    public static class TreeNode {
        int val = 0;
        TreeNode left = null;
        TreeNode right = null;
        TreeNode(int val){
            this.val = val;
        }
    }
}
